package com.wu.client.controller;

import com.wu.client.service.SongService;
import com.wu.client.vo.res.PageResp;
import com.wu.client.vo.res.album.AlbumBaseResp;
import com.wu.client.vo.res.song.SongBaseResp;
import com.wu.client.vo.res.song.SongResp;
import com.wu.common.convertion.result.Result;
import com.wu.common.convertion.result.Results;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Cousin
 * @date 2025/3/16
 * @Description
 */
@RestController
@RequestMapping("songs")
@RequiredArgsConstructor
public class SongController {
    private final SongService songService;

    ///http://localhost:8888/api/songs/artist/1?userId=1&page=1&limit=10
    @GetMapping("/artist/{artistId}")
    public Result<PageResp<SongResp>> getArtistSongs(@PathVariable Long artistId, @RequestParam(required = false) Long userId
            , @RequestParam(defaultValue = "1") Integer page, @RequestParam (defaultValue = "5") Integer limit){
        return Results.success(songService.getArtistSongs(artistId,userId,page,limit));
    }

    @GetMapping("/playlist/{playlistId}")
    public Result<PageResp<SongResp>> getPlaylistSongs(@PathVariable Long playlistId, @RequestParam(required = false) Long userId
            , @RequestParam(defaultValue = "1") Integer page, @RequestParam (defaultValue = "5") Integer limit){
        return Results.success(songService.getArtistSongs(playlistId,userId,page,limit));
    }
    @GetMapping("/album/{albumId}")
    public Result<PageResp<SongResp>> getAlbumSongs(@PathVariable Long albumId, @RequestParam(required = false) Long userId
            , @RequestParam(defaultValue = "1") Integer page, @RequestParam (defaultValue = "5") Integer limit){
        return Results.success(songService.getArtistSongs(albumId,userId,page,limit));
    }
    @GetMapping("query")
    public Object queryInPage(@RequestParam Integer page,@RequestParam Integer limit,@RequestParam String query){
        return Results.success(songService.getArtistSongs(1L,null,page,limit));
    }

}
